{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "546f9943-407a-4ac1-87bf-9b488186a307",
   "metadata": {},
   "source": [
    "# Single Factor Model\n",
    "## About\n",
    "Casual observation of stock prices reveals that when the market goes up (as measured by\n",
    "any of the widely available stock market indexes ), most stocks tend to increase in price\n",
    "and when the market goes down, most stocks tend to decrease in price. This suggests that\n",
    "one reason security retuns might be correlated is because of a common response to mar-\n",
    "ket changes, and a useful measure of this correlation might be obtained by relating the\n",
    "return on a stock to the retum on a stock market index. The return on a stock can be writ\n",
    "ten as\n",
    "$$R_{i}=\\alpha_{i}+\\beta_{i} R_{m}+e_{i}$$\n",
    "where\n",
    "$\\beta_i$ measures the sensitivity of a stock return to the market return\n",
    "$alpha_i$ is the abnormal return offered by the asset i\n",
    "$e_i$ is the error term."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9e113d7d-45f9-40d2-8a6f-ea1ce9e6bc82",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import statsmodels.api as sm\n",
    "import matplotlib. pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ba405075-1865-42e2-a684-d2f0113a60df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>沪深300</th>\n",
       "      <th>采矿指数</th>\n",
       "      <th>制造指数</th>\n",
       "      <th>批发零售指数</th>\n",
       "      <th>运输指数</th>\n",
       "      <th>IT指数</th>\n",
       "      <th>金融指数</th>\n",
       "      <th>地产指数</th>\n",
       "      <th>科研指数</th>\n",
       "      <th>文化指数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-01-02</th>\n",
       "      <td>1443.1356</td>\n",
       "      <td>1362.7822</td>\n",
       "      <td>1204.4316</td>\n",
       "      <td>912.2444</td>\n",
       "      <td>1276.0392</td>\n",
       "      <td>794.0103</td>\n",
       "      <td>2161.8660</td>\n",
       "      <td>1376.5101</td>\n",
       "      <td>857.0707</td>\n",
       "      <td>2969.5353</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-03</th>\n",
       "      <td>1462.1588</td>\n",
       "      <td>1348.6177</td>\n",
       "      <td>1204.7603</td>\n",
       "      <td>908.8393</td>\n",
       "      <td>1263.7309</td>\n",
       "      <td>807.9592</td>\n",
       "      <td>2155.3205</td>\n",
       "      <td>1355.4252</td>\n",
       "      <td>853.7124</td>\n",
       "      <td>2964.8421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-04</th>\n",
       "      <td>1493.1061</td>\n",
       "      <td>1380.6088</td>\n",
       "      <td>1242.2284</td>\n",
       "      <td>925.7469</td>\n",
       "      <td>1310.4872</td>\n",
       "      <td>859.5181</td>\n",
       "      <td>2209.0098</td>\n",
       "      <td>1393.0800</td>\n",
       "      <td>870.2878</td>\n",
       "      <td>3035.8741</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-07</th>\n",
       "      <td>1511.7773</td>\n",
       "      <td>1407.9401</td>\n",
       "      <td>1255.5552</td>\n",
       "      <td>934.8374</td>\n",
       "      <td>1345.7394</td>\n",
       "      <td>859.8571</td>\n",
       "      <td>2228.3911</td>\n",
       "      <td>1421.5129</td>\n",
       "      <td>886.5827</td>\n",
       "      <td>3054.3030</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-08</th>\n",
       "      <td>1490.0182</td>\n",
       "      <td>1408.2477</td>\n",
       "      <td>1251.5597</td>\n",
       "      <td>932.5704</td>\n",
       "      <td>1336.8775</td>\n",
       "      <td>856.3896</td>\n",
       "      <td>2217.4064</td>\n",
       "      <td>1415.8969</td>\n",
       "      <td>883.9005</td>\n",
       "      <td>3047.7035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-09</th>\n",
       "      <td>1489.9021</td>\n",
       "      <td>1418.5058</td>\n",
       "      <td>1263.1401</td>\n",
       "      <td>938.1820</td>\n",
       "      <td>1339.6711</td>\n",
       "      <td>862.7519</td>\n",
       "      <td>2233.3804</td>\n",
       "      <td>1414.5300</td>\n",
       "      <td>881.5499</td>\n",
       "      <td>3078.4759</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-10</th>\n",
       "      <td>1494.4361</td>\n",
       "      <td>1416.8906</td>\n",
       "      <td>1258.7475</td>\n",
       "      <td>932.2336</td>\n",
       "      <td>1337.3327</td>\n",
       "      <td>854.4044</td>\n",
       "      <td>2218.3880</td>\n",
       "      <td>1414.5262</td>\n",
       "      <td>880.4076</td>\n",
       "      <td>3072.6864</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-11</th>\n",
       "      <td>1494.7089</td>\n",
       "      <td>1428.3912</td>\n",
       "      <td>1263.7175</td>\n",
       "      <td>938.2605</td>\n",
       "      <td>1348.4922</td>\n",
       "      <td>860.8123</td>\n",
       "      <td>2232.1566</td>\n",
       "      <td>1417.8260</td>\n",
       "      <td>886.6795</td>\n",
       "      <td>3094.7782</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-14</th>\n",
       "      <td>1498.0099</td>\n",
       "      <td>1418.6451</td>\n",
       "      <td>1260.1189</td>\n",
       "      <td>937.3666</td>\n",
       "      <td>1330.4244</td>\n",
       "      <td>854.2330</td>\n",
       "      <td>2211.7089</td>\n",
       "      <td>1411.7977</td>\n",
       "      <td>878.1687</td>\n",
       "      <td>3067.7845</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-15</th>\n",
       "      <td>1512.6408</td>\n",
       "      <td>1442.9074</td>\n",
       "      <td>1279.8510</td>\n",
       "      <td>944.7083</td>\n",
       "      <td>1355.6769</td>\n",
       "      <td>871.5347</td>\n",
       "      <td>2231.4354</td>\n",
       "      <td>1426.2137</td>\n",
       "      <td>887.7622</td>\n",
       "      <td>3127.9904</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                沪深300       采矿指数       制造指数    批发零售指数       运输指数      IT指数  \\\n",
       "trade_date                                                                   \n",
       "2019-01-02  1443.1356  1362.7822  1204.4316  912.2444  1276.0392  794.0103   \n",
       "2019-01-03  1462.1588  1348.6177  1204.7603  908.8393  1263.7309  807.9592   \n",
       "2019-01-04  1493.1061  1380.6088  1242.2284  925.7469  1310.4872  859.5181   \n",
       "2019-01-07  1511.7773  1407.9401  1255.5552  934.8374  1345.7394  859.8571   \n",
       "2019-01-08  1490.0182  1408.2477  1251.5597  932.5704  1336.8775  856.3896   \n",
       "2019-01-09  1489.9021  1418.5058  1263.1401  938.1820  1339.6711  862.7519   \n",
       "2019-01-10  1494.4361  1416.8906  1258.7475  932.2336  1337.3327  854.4044   \n",
       "2019-01-11  1494.7089  1428.3912  1263.7175  938.2605  1348.4922  860.8123   \n",
       "2019-01-14  1498.0099  1418.6451  1260.1189  937.3666  1330.4244  854.2330   \n",
       "2019-01-15  1512.6408  1442.9074  1279.8510  944.7083  1355.6769  871.5347   \n",
       "\n",
       "                 金融指数       地产指数      科研指数       文化指数  \n",
       "trade_date                                             \n",
       "2019-01-02  2161.8660  1376.5101  857.0707  2969.5353  \n",
       "2019-01-03  2155.3205  1355.4252  853.7124  2964.8421  \n",
       "2019-01-04  2209.0098  1393.0800  870.2878  3035.8741  \n",
       "2019-01-07  2228.3911  1421.5129  886.5827  3054.3030  \n",
       "2019-01-08  2217.4064  1415.8969  883.9005  3047.7035  \n",
       "2019-01-09  2233.3804  1414.5300  881.5499  3078.4759  \n",
       "2019-01-10  2218.3880  1414.5262  880.4076  3072.6864  \n",
       "2019-01-11  2232.1566  1417.8260  886.6795  3094.7782  \n",
       "2019-01-14  2211.7089  1411.7977  878.1687  3067.7845  \n",
       "2019-01-15  2231.4354  1426.2137  887.7622  3127.9904  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df=pd.read_csv('stocks_index.csv',encoding='utf_8_sig')\n",
    "df['trade_date'] = pd.to_datetime(df['trade_date'])\n",
    "df2 = df.reset_index().set_index('trade_date')\n",
    "df2 = df2.drop(['index'],axis=1)\n",
    "df2.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "08193e70-5144-4d44-8955-e07e49027d55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>沪深300</th>\n",
       "      <th>采矿指数</th>\n",
       "      <th>制造指数</th>\n",
       "      <th>批发零售指数</th>\n",
       "      <th>运输指数</th>\n",
       "      <th>IT指数</th>\n",
       "      <th>金融指数</th>\n",
       "      <th>地产指数</th>\n",
       "      <th>科研指数</th>\n",
       "      <th>文化指数</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>trade_date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-01-03</th>\n",
       "      <td>0.013096</td>\n",
       "      <td>-0.010448</td>\n",
       "      <td>0.000273</td>\n",
       "      <td>-0.003740</td>\n",
       "      <td>-0.009693</td>\n",
       "      <td>0.017415</td>\n",
       "      <td>-0.003032</td>\n",
       "      <td>-0.015436</td>\n",
       "      <td>-0.003926</td>\n",
       "      <td>-0.001582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-04</th>\n",
       "      <td>0.020945</td>\n",
       "      <td>0.023444</td>\n",
       "      <td>0.030626</td>\n",
       "      <td>0.018433</td>\n",
       "      <td>0.036331</td>\n",
       "      <td>0.061860</td>\n",
       "      <td>0.024605</td>\n",
       "      <td>0.027402</td>\n",
       "      <td>0.019230</td>\n",
       "      <td>0.023676</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-07</th>\n",
       "      <td>0.012427</td>\n",
       "      <td>0.019603</td>\n",
       "      <td>0.010671</td>\n",
       "      <td>0.009772</td>\n",
       "      <td>0.026545</td>\n",
       "      <td>0.000394</td>\n",
       "      <td>0.008735</td>\n",
       "      <td>0.020205</td>\n",
       "      <td>0.018550</td>\n",
       "      <td>0.006052</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-08</th>\n",
       "      <td>-0.014498</td>\n",
       "      <td>0.000218</td>\n",
       "      <td>-0.003187</td>\n",
       "      <td>-0.002428</td>\n",
       "      <td>-0.006607</td>\n",
       "      <td>-0.004041</td>\n",
       "      <td>-0.004942</td>\n",
       "      <td>-0.003959</td>\n",
       "      <td>-0.003030</td>\n",
       "      <td>-0.002163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-09</th>\n",
       "      <td>-0.000078</td>\n",
       "      <td>0.007258</td>\n",
       "      <td>0.009210</td>\n",
       "      <td>0.005999</td>\n",
       "      <td>0.002087</td>\n",
       "      <td>0.007402</td>\n",
       "      <td>0.007178</td>\n",
       "      <td>-0.000966</td>\n",
       "      <td>-0.002663</td>\n",
       "      <td>0.010046</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-10</th>\n",
       "      <td>0.003039</td>\n",
       "      <td>-0.001139</td>\n",
       "      <td>-0.003484</td>\n",
       "      <td>-0.006361</td>\n",
       "      <td>-0.001747</td>\n",
       "      <td>-0.009723</td>\n",
       "      <td>-0.006736</td>\n",
       "      <td>-0.000003</td>\n",
       "      <td>-0.001297</td>\n",
       "      <td>-0.001882</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-11</th>\n",
       "      <td>0.000183</td>\n",
       "      <td>0.008084</td>\n",
       "      <td>0.003941</td>\n",
       "      <td>0.006444</td>\n",
       "      <td>0.008310</td>\n",
       "      <td>0.007472</td>\n",
       "      <td>0.006187</td>\n",
       "      <td>0.002330</td>\n",
       "      <td>0.007099</td>\n",
       "      <td>0.007164</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-14</th>\n",
       "      <td>0.002206</td>\n",
       "      <td>-0.006847</td>\n",
       "      <td>-0.002852</td>\n",
       "      <td>-0.000953</td>\n",
       "      <td>-0.013489</td>\n",
       "      <td>-0.007672</td>\n",
       "      <td>-0.009203</td>\n",
       "      <td>-0.004261</td>\n",
       "      <td>-0.009645</td>\n",
       "      <td>-0.008761</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-15</th>\n",
       "      <td>0.009720</td>\n",
       "      <td>0.016958</td>\n",
       "      <td>0.015538</td>\n",
       "      <td>0.007802</td>\n",
       "      <td>0.018803</td>\n",
       "      <td>0.020052</td>\n",
       "      <td>0.008880</td>\n",
       "      <td>0.010159</td>\n",
       "      <td>0.010865</td>\n",
       "      <td>0.019435</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-01-16</th>\n",
       "      <td>-0.003834</td>\n",
       "      <td>-0.002946</td>\n",
       "      <td>0.003524</td>\n",
       "      <td>0.000652</td>\n",
       "      <td>-0.002448</td>\n",
       "      <td>-0.002788</td>\n",
       "      <td>0.003680</td>\n",
       "      <td>-0.002620</td>\n",
       "      <td>0.010605</td>\n",
       "      <td>0.000211</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               沪深300      采矿指数      制造指数    批发零售指数      运输指数      IT指数  \\\n",
       "trade_date                                                               \n",
       "2019-01-03  0.013096 -0.010448  0.000273 -0.003740 -0.009693  0.017415   \n",
       "2019-01-04  0.020945  0.023444  0.030626  0.018433  0.036331  0.061860   \n",
       "2019-01-07  0.012427  0.019603  0.010671  0.009772  0.026545  0.000394   \n",
       "2019-01-08 -0.014498  0.000218 -0.003187 -0.002428 -0.006607 -0.004041   \n",
       "2019-01-09 -0.000078  0.007258  0.009210  0.005999  0.002087  0.007402   \n",
       "2019-01-10  0.003039 -0.001139 -0.003484 -0.006361 -0.001747 -0.009723   \n",
       "2019-01-11  0.000183  0.008084  0.003941  0.006444  0.008310  0.007472   \n",
       "2019-01-14  0.002206 -0.006847 -0.002852 -0.000953 -0.013489 -0.007672   \n",
       "2019-01-15  0.009720  0.016958  0.015538  0.007802  0.018803  0.020052   \n",
       "2019-01-16 -0.003834 -0.002946  0.003524  0.000652 -0.002448 -0.002788   \n",
       "\n",
       "                金融指数      地产指数      科研指数      文化指数  \n",
       "trade_date                                          \n",
       "2019-01-03 -0.003032 -0.015436 -0.003926 -0.001582  \n",
       "2019-01-04  0.024605  0.027402  0.019230  0.023676  \n",
       "2019-01-07  0.008735  0.020205  0.018550  0.006052  \n",
       "2019-01-08 -0.004942 -0.003959 -0.003030 -0.002163  \n",
       "2019-01-09  0.007178 -0.000966 -0.002663  0.010046  \n",
       "2019-01-10 -0.006736 -0.000003 -0.001297 -0.001882  \n",
       "2019-01-11  0.006187  0.002330  0.007099  0.007164  \n",
       "2019-01-14 -0.009203 -0.004261 -0.009645 -0.008761  \n",
       "2019-01-15  0.008880  0.010159  0.010865  0.019435  \n",
       "2019-01-16  0.003680 -0.002620  0.010605  0.000211  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns = np.log(df2/df2.shift(1))\n",
    "returns = returns.dropna()\n",
    "returns.head(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9aaa2aa3-76b8-494b-884a-61eb8ba6cb2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>沪深300</th>\n",
       "      <th>采矿指数</th>\n",
       "      <th>制造指数</th>\n",
       "      <th>批发零售指数</th>\n",
       "      <th>运输指数</th>\n",
       "      <th>IT指数</th>\n",
       "      <th>金融指数</th>\n",
       "      <th>地产指数</th>\n",
       "      <th>科研指数</th>\n",
       "      <th>文化指数</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "      <td>228.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>0.000534</td>\n",
       "      <td>0.001423</td>\n",
       "      <td>0.000571</td>\n",
       "      <td>0.000526</td>\n",
       "      <td>0.001347</td>\n",
       "      <td>0.001326</td>\n",
       "      <td>0.000624</td>\n",
       "      <td>0.000838</td>\n",
       "      <td>0.000314</td>\n",
       "      <td>0.001196</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>0.016191</td>\n",
       "      <td>0.015271</td>\n",
       "      <td>0.014844</td>\n",
       "      <td>0.013579</td>\n",
       "      <td>0.020774</td>\n",
       "      <td>0.018749</td>\n",
       "      <td>0.014830</td>\n",
       "      <td>0.015831</td>\n",
       "      <td>0.017699</td>\n",
       "      <td>0.012700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>-0.075212</td>\n",
       "      <td>-0.079859</td>\n",
       "      <td>-0.070984</td>\n",
       "      <td>-0.070400</td>\n",
       "      <td>-0.094542</td>\n",
       "      <td>-0.081506</td>\n",
       "      <td>-0.069670</td>\n",
       "      <td>-0.078655</td>\n",
       "      <td>-0.080684</td>\n",
       "      <td>-0.060192</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>-0.007890</td>\n",
       "      <td>-0.006787</td>\n",
       "      <td>-0.006356</td>\n",
       "      <td>-0.006397</td>\n",
       "      <td>-0.009688</td>\n",
       "      <td>-0.008936</td>\n",
       "      <td>-0.007603</td>\n",
       "      <td>-0.006564</td>\n",
       "      <td>-0.008410</td>\n",
       "      <td>-0.004785</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>0.000565</td>\n",
       "      <td>0.001470</td>\n",
       "      <td>0.000229</td>\n",
       "      <td>0.001033</td>\n",
       "      <td>-0.000535</td>\n",
       "      <td>0.000213</td>\n",
       "      <td>-0.000096</td>\n",
       "      <td>-0.000189</td>\n",
       "      <td>-0.000351</td>\n",
       "      <td>0.000382</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>0.010791</td>\n",
       "      <td>0.008935</td>\n",
       "      <td>0.008457</td>\n",
       "      <td>0.007977</td>\n",
       "      <td>0.010711</td>\n",
       "      <td>0.008774</td>\n",
       "      <td>0.008751</td>\n",
       "      <td>0.008961</td>\n",
       "      <td>0.010036</td>\n",
       "      <td>0.007219</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>0.045165</td>\n",
       "      <td>0.049936</td>\n",
       "      <td>0.048221</td>\n",
       "      <td>0.041901</td>\n",
       "      <td>0.071141</td>\n",
       "      <td>0.089913</td>\n",
       "      <td>0.051684</td>\n",
       "      <td>0.054953</td>\n",
       "      <td>0.058186</td>\n",
       "      <td>0.057775</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            沪深300        采矿指数        制造指数      批发零售指数        运输指数        IT指数  \\\n",
       "count  228.000000  228.000000  228.000000  228.000000  228.000000  228.000000   \n",
       "mean     0.000534    0.001423    0.000571    0.000526    0.001347    0.001326   \n",
       "std      0.016191    0.015271    0.014844    0.013579    0.020774    0.018749   \n",
       "min     -0.075212   -0.079859   -0.070984   -0.070400   -0.094542   -0.081506   \n",
       "25%     -0.007890   -0.006787   -0.006356   -0.006397   -0.009688   -0.008936   \n",
       "50%      0.000565    0.001470    0.000229    0.001033   -0.000535    0.000213   \n",
       "75%      0.010791    0.008935    0.008457    0.007977    0.010711    0.008774   \n",
       "max      0.045165    0.049936    0.048221    0.041901    0.071141    0.089913   \n",
       "\n",
       "             金融指数        地产指数        科研指数        文化指数  \n",
       "count  228.000000  228.000000  228.000000  228.000000  \n",
       "mean     0.000624    0.000838    0.000314    0.001196  \n",
       "std      0.014830    0.015831    0.017699    0.012700  \n",
       "min     -0.069670   -0.078655   -0.080684   -0.060192  \n",
       "25%     -0.007603   -0.006564   -0.008410   -0.004785  \n",
       "50%     -0.000096   -0.000189   -0.000351    0.000382  \n",
       "75%      0.008751    0.008961    0.010036    0.007219  \n",
       "max      0.051684    0.054953    0.058186    0.057775  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "returns.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45b8a420-0dfe-4a89-a305-386a10b3e880",
   "metadata": {},
   "source": [
    "## OLS in python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0b1bb95a-3716-4b43-a327-217763f6b8d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Hubu\\anaconda3\\lib\\site-packages\\statsmodels\\tsa\\tsatools.py:142: FutureWarning: In a future version of pandas all arguments of concat except for the argument 'objs' will be keyword-only\n",
      "  x = pd.concat(x[::order], 1)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table class=\"simpletable\">\n",
       "<caption>OLS Regression Results</caption>\n",
       "<tr>\n",
       "  <th>Dep. Variable:</th>          <td>IT指数</td>       <th>  R-squared:         </th> <td>   0.452</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Model:</th>                   <td>OLS</td>       <th>  Adj. R-squared:    </th> <td>   0.449</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Method:</th>             <td>Least Squares</td>  <th>  F-statistic:       </th> <td>   186.2</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Date:</th>             <td>Sun, 13 Mar 2022</td> <th>  Prob (F-statistic):</th> <td>2.50e-31</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Time:</th>                 <td>17:38:10</td>     <th>  Log-Likelihood:    </th> <td>  652.18</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>No. Observations:</th>      <td>   228</td>      <th>  AIC:               </th> <td>  -1300.</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Df Residuals:</th>          <td>   226</td>      <th>  BIC:               </th> <td>  -1293.</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Df Model:</th>              <td>     1</td>      <th>                     </th>     <td> </td>   \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Covariance Type:</th>      <td>nonrobust</td>    <th>                     </th>     <td> </td>   \n",
       "</tr>\n",
       "</table>\n",
       "<table class=\"simpletable\">\n",
       "<tr>\n",
       "    <td></td>       <th>coef</th>     <th>std err</th>      <th>t</th>      <th>P>|t|</th>  <th>[0.025</th>    <th>0.975]</th>  \n",
       "</tr>\n",
       "<tr>\n",
       "  <th>const</th> <td>    0.0009</td> <td>    0.001</td> <td>    0.988</td> <td> 0.324</td> <td>   -0.001</td> <td>    0.003</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>沪深300</th> <td>    0.7783</td> <td>    0.057</td> <td>   13.647</td> <td> 0.000</td> <td>    0.666</td> <td>    0.891</td>\n",
       "</tr>\n",
       "</table>\n",
       "<table class=\"simpletable\">\n",
       "<tr>\n",
       "  <th>Omnibus:</th>       <td>29.336</td> <th>  Durbin-Watson:     </th> <td>   2.163</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Prob(Omnibus):</th> <td> 0.000</td> <th>  Jarque-Bera (JB):  </th> <td>  56.404</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Skew:</th>          <td> 0.661</td> <th>  Prob(JB):          </th> <td>5.65e-13</td>\n",
       "</tr>\n",
       "<tr>\n",
       "  <th>Kurtosis:</th>      <td> 5.046</td> <th>  Cond. No.          </th> <td>    61.9</td>\n",
       "</tr>\n",
       "</table><br/><br/>Notes:<br/>[1] Standard Errors assume that the covariance matrix of the errors is correctly specified."
      ],
      "text/plain": [
       "<class 'statsmodels.iolib.summary.Summary'>\n",
       "\"\"\"\n",
       "                            OLS Regression Results                            \n",
       "==============================================================================\n",
       "Dep. Variable:                   IT指数   R-squared:                       0.452\n",
       "Model:                            OLS   Adj. R-squared:                  0.449\n",
       "Method:                 Least Squares   F-statistic:                     186.2\n",
       "Date:                Sun, 13 Mar 2022   Prob (F-statistic):           2.50e-31\n",
       "Time:                        17:38:10   Log-Likelihood:                 652.18\n",
       "No. Observations:                 228   AIC:                            -1300.\n",
       "Df Residuals:                     226   BIC:                            -1293.\n",
       "Df Model:                           1                                         \n",
       "Covariance Type:            nonrobust                                         \n",
       "==============================================================================\n",
       "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
       "------------------------------------------------------------------------------\n",
       "const          0.0009      0.001      0.988      0.324      -0.001       0.003\n",
       "沪深300          0.7783      0.057     13.647      0.000       0.666       0.891\n",
       "==============================================================================\n",
       "Omnibus:                       29.336   Durbin-Watson:                   2.163\n",
       "Prob(Omnibus):                  0.000   Jarque-Bera (JB):               56.404\n",
       "Skew:                           0.661   Prob(JB):                     5.65e-13\n",
       "Kurtosis:                       5.046   Cond. No.                         61.9\n",
       "==============================================================================\n",
       "\n",
       "Notes:\n",
       "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
       "\"\"\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "R=returns['IT指数']\n",
    "R_index=returns['沪深300']\n",
    "R_index_con=sm.add_constant(R_index)\n",
    "model = sm.OLS(endog=R,exog=R_index_con)\n",
    "results = model.fit()\n",
    "alpha,beta=results.params\n",
    "results.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "9e0d1496-9143-4420-a74f-49aa3c81e1a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x178a80a6ca0>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAD4CAYAAAAZ1BptAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bG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SwsGCUvLYYwxxlO6j24yxhjTjCxIGGOM8WRBwhhjjCcLEsYYYzxZkDDGGOPJgoQxxhhPFiSMMcZ4+v81VKr+fz/w1wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.figure()\n",
    "plt.scatter(returns['沪深300'], returns['IT指数'],  marker = 'o')\n",
    "cml = lambda x: alpha+beta*x\n",
    "x = np.linspace(min(returns['沪深300']),max(returns['沪深300']),100)\n",
    "y = [cml(i) for i in x]\n",
    "plt.plot(x,y,c='red')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f4df97c-5c7f-4927-87e6-35031587cb5c",
   "metadata": {},
   "source": [
    "## Exercise 1:\n",
    "\n",
    "    1. Write a code to calculate MSE of the above model;\n",
    "    \n",
    "    2. Fill in the blankets of the following table;\n",
    "    \n",
    "    3. Try to explain the single factor model economically;\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "64c77ad6-457e-4104-9d9c-93d38945b136",
   "metadata": {},
   "source": [
    "|       | 采矿指数 | 制造指数 | 批发零售指数 | 运输指数 | IT指数 | 金融指数 | 地产指数 | 科研指数 | 文化指数 |\n",
    "| ----- | -------- | -------- | ------------ | -------- | ------ | -------- | -------- | -------- | -------- |\n",
    "| Alpha |          |          |              |          | 0.0009       |          |          |          |          |\n",
    "| Beta  |          |          |              |          | 0.7783       |          |          |          |          |\n",
    "| R^2 |          |          |              |          | 0.452       |          |          |          |          |\n",
    "| MSE  |          |          |              |          | 0.7783       |          |          |          |          |\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "eb4a3437-bc27-4a90-9bce-8be912916821",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = returns['沪深300']\n",
    "y = returns['IT指数']\n",
    "yp = alpha+beta*x\n",
    "resid = y - yp\n",
    "rss=np.sum(resid**2)\n",
    "MSE=rss/(results.nobs-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2e2204c2-dabe-4e34-8138-075b333e70a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.00019270998052870231"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "MSE\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b2c9e2f2-6d73-48a8-a146-33b422f42032",
   "metadata": {},
   "source": [
    "# CAPM Model\n",
    "## About\n",
    "The single factor model is related to the Capital Asset Pricing Model (CAPM), which explains that investors need to be compensated for two main things: time value and risk.  The time value portion of the return is captured by a risk-free rate.  The risk of a security is captured by a risk measure that compares returns of the asset to returns of the market (a market premium).  In form:\n",
    "$$R_{a}=r_{f}+\\beta_{a}\\left(R_{m}-R_{f}\\right)$$\n",
    "where\n",
    "$r_f$ is the risk free rate\n",
    "$\\beta_{a}$ is the beta of the security\n",
    "$R_m$ is the market return."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "7e3796c5-cb15-43ca-adb1-9e8386664866",
   "metadata": {},
   "outputs": [],
   "source": [
    "def CAPM(beta,Rm,Ra):\n",
    "    Ri = Rf+beta*(Rm-Rf)\n",
    "    return Ri"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a8c108e-c7ba-40c0-9c3f-56025849a3ec",
   "metadata": {},
   "source": [
    "## Exercise 2\n",
    "Assume Rf=0.385, beta ranges from zero to two, please draw the SML(security market line) by python."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4bd4e097-ef47-4b6f-8087-c8566729b66a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
